<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>发起工单</title>
    <link href="${pageContext.request.contextPath}/static/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/css/fonts.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/css/style2.css" rel="stylesheet">
    <style>
        button {
            width: 150px;
            height: auto;
        }

        #failBtn {
            float: right;
        }
    </style>
</head>
<body>
<main class="ftdms-layout-content">
    <div class="container-fluid" style="margin-bottom:90px;padding: 0px">
        <div class="row" style="margin-top:15px;">
            <div class="col-lg-12">
                <div class="card">
                    <div class="tab-content">
                        <div class="tab-pane active">
                            <div class="form-group">
                                <label for="nickName">姓名</label>
                                <input class="form-control" type="text" id="nickName" name="nickName"
                                       value="${checkUser.nickName}" readonly>
                                <input type="hidden" name="userId" value="1">
                            </div>
                            <div class="form-group">
                                <label for="password">密码</label>
                                <input class="form-control" type="text" id="password" name="password"
                                       value="${checkUser.password}" readonly>
                                <input type="hidden" name="userId" value="1">
                            </div>
                            <div class="form-group">
                                <label for="sex">性别</label>
                                <input class="form-control" type="text" id="sex" name="sex"
                                       value="${checkUser.sex}" readonly>
                                <input type="hidden" name="userId" value="1">
                            </div>
                            <div class="form-group">
                                <label for="phone">手机</label>
                                <input class="form-control" type="text" id="phone" name="phone"
                                       value="${checkUser.phone}" readonly>
                                <input type="hidden" name="userId" value="1">
                            </div>
                            <div class="form-group">
                                <label class="btn-block" for="isUpdate">修改信息</label>
                                <label class="ftdms-switch switch-solid switch-primary">
                                    <input type="checkbox" id="isUpdate" class="isUpdate">
                                    <span></span>
                                </label>
                            </div>
                            <div class="form-group" id="btnList" style="display: none">
                                <button id="updateBtn" type="button" class="back btn btn-primary m-r-5" value="1"
                                        onclick="javascript:;">确认修改
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</main>
</body>
<script src="${pageContext.request.contextPath}/static/js/jquery3.4.1.js"></script>
<script src="${pageContext.request.contextPath}/static/layer/layer.js"></script>
<!--初始化-->
<script>
    window.onload = function () {
        let nickName = $("#nickName").val();
        $("#isUpdate").prop("checked", false);

        $("#isUpdate").click(function () {
            let checked = $(this).prop("checked");
            if (checked) {
                layer.confirm('确认修改' + nickName + "的信息吗", {
                    btn: ['确认', '取消',] //可以无限个按钮
                }, function (index, layero) {
                    $(".form-control").prop("readOnly", false);
                    $("#btnList").show();
                    layer.close(index);
                }, function (index) {
                    $(".form-control").prop("readOnly", true);
                    $("#btnList").hide();
                    $("#isUpdate").prop("checked", false);
                });
            } else {
                $(".form-control").prop("readOnly", true);
                $("#btnList").hide();
            }
        });
    }

    $("#fo")

    $("#updateBtn").click(function () {
        layer.confirm('确认要完成修改？', {
            btn: ['确认', '取消'] //按钮
        }, function () {
            $.ajax({
                url: "${pageContext.request.contextPath}/user/updateUser.handler",
                data: {
                    id: ${checkUser.id},
                    nickName: $("#nickName").val(),
                    password: $("#password").val(),
                    sex: $("#sex").val(),
                    phone: $("#phone").val()
                },
                success: function (data) {
                    if (data.state) {
                        layer.msg('修改成功！！！', {time: 2000, icon: 6}, function () {
                            let index = parent.layer.getFrameIndex(window.name);
                            parent.layui.table.reload('allUser-form');
                            parent.layer.close(index);
                        });
                    } else {
                        layer.msg('修改失败，请重新尝试！！！', {time: 2000, icon: 5});
                    }
                }
            });
        });
    })
</script>
</html>

